home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / a / a_funk / satellit.tos / SATELLIT / SAT_SOUR.TXT / DOVE_SAT.C next >
Encoding:
C/C++ Source or Header  |  1995-04-30  |  11.4 KB  |  386 lines

  1. 19Sep90/1115  Subject: dove telemetrie programm (info) de DH8BAG @ DB0HB
  2.  
  3. Nachdem es mir neulich gelungen ist, mit einfachsten Mitteln ein paar Telemetrie-
  4. blöcke von DO-17 aufzufangen, habe ich mich drangesetzt und ein Dekoder-
  5. Programm geschrieben. Einige Programme, die ich aus der Box geholt hatte,
  6. wollten aus irgendwelchen Gründen nicht so, wie ich wollte.
  7. Nachdem eine Anzeige im Textmode schnell fertig war, bin ich daran gegangen
  8. und habe mir als Gag eine Anzeige auf simulierten Analoginstrumenten aus-
  9. gedacht.
  10. Aus Portabilitätsgründen habe ich mich für die BGI Grafik entschieden. die
  11. Geschichte sollte also auch ungefähr auf dem PC und seinen Brüdern laufen.
  12. aber das Überschreiben des Meβwerts führt beim PC nicht dazu, daβ der alte
  13. Text gelöscht wird ... zumindest hier muβ man noch was tun ...
  14. Das ganze besteht aus drei Files:
  15. 1.) dovetlm.c - das Hauptprogramm
  16. 2.) analog.c  - Unterprogramme für die Analog-Instrumente
  17. 3.) analog.h  - das Header-File dazu
  18. Wer gefallen an meinen "Analog" Instrumenten findet, darf sie gerne für andere
  19. Zwecke "miβbrauchen".
  20. 73 und viel Spaβ damit
  21. Guido (DH8BAG @ DB0HB)
  22.  
  23. 19Sep90/1117  Subject: dove tlm 1/3   de DH8BAG @ DB0HB
  24.  
  25. /* File analog.h */
  26. typedef struct {
  27.         int x,y;
  28.         char unit[10];
  29.         int a,e;
  30.         int cx,cy;
  31.         double val;
  32.         char remark[20];
  33. } INSTRUMENT;
  34.  
  35. void init_inst(INSTRUMENT *,int,int,char *,int,int,char *);
  36. void draw_inst(INSTRUMENT *);
  37. void update_inst(INSTRUMENT *,double);
  38.  
  39. 19Sep90/1136  Subject: dove tlm 2/3  de DH8BAG @ DB0HB
  40.  
  41. /* File analog.c */
  42. #include <cport.h>
  43. #include <graphics.h>
  44. #include <ext.h>
  45. #include <string.h>
  46. #include <stdlib.h>
  47. #include <math.h>
  48. #include "analog.h"
  49.  
  50. void init_inst(INSTRUMENT *in,int x,int y,char *u,int a,int e,char *rem)
  51. {
  52.         in->x=x;
  53.         in->y=y;
  54.         strcpy(in->unit,u);
  55.         in->a=a;
  56.         in->e=e;
  57.         in->cx=x+60;
  58.         in->cy=y+70;
  59.         in->val=0.0;
  60.         if (rem)
  61.                 strcpy(in->remark,rem);
  62.         else
  63.                 strcpy(in->remark,"");
  64. }
  65.  
  66. void draw_inst(INSTRUMENT *in)
  67. {
  68.         int angl;
  69.         double u,v;
  70.         int i;
  71.         char s[10],help[30];
  72.     int skalen_end_wert;
  73.     int faktor=1;
  74.  
  75.         rectangle(in->x,in->y,in->x+120,in->y+82);
  76.         outtextxy(in->cx-4*strlen(in->remark),in->y+84,in->remark);
  77.         arc(in->cx,in->cy,45,135,50);
  78.     sprintf(help,"%6.2f %s",in->val,in->unit);
  79.     outtextxy(in->cx-4*strlen(help),in->y+65,help);
  80.     skalen_end_wert=in->e;
  81.     while (skalen_end_wert>20) {
  82.         skalen_end_wert/=10;
  83.         faktor*=10;
  84.     }
  85.     if (faktor>1)
  86.         sprintf(help,"%s (*%d)",in->unit,faktor);
  87.     else strcpy(help,in->unit);
  88.         outtextxy(in->cx-strlen(help)*4,in->y+40,help);
  89.         for(i=0;i<=skalen_end_wert;i++) {
  90.             angl=135-((int)i*90*faktor/in->e);
  91.                 u=cos(angl*M_PI/180.0);
  92.                 v=sin(angl*M_PI/180.0);
  93.                 if (i%5 && !(skalen_end_wert < 5))
  94.                         line((int)in->cx+u*50,(int)in->cy-v*50,(int)in->cx+u*55,(int)in->cy-v*55);
  95.                 else {
  96.                         line((int)in->cx+u*50,(int)in->cy-v*50,(int)in->cx+u*60,(int)in->cy-v*60);
  97.                     itoa(i,s,10);
  98.                     outtextxy((int)in->cx+u*69-4*strlen(s),(int)in->cy-v*69,s);
  99.                 }
  100.         }
  101.     setwritemode(XOR_PUT);
  102.     angl=135-(int)(in->val*0.9);
  103.     u=cos(angl*M_PI/180.0);
  104.     v=sin(angl*M_PI/180.0);
  105.     line(in->cx,in->cy,(int)in->cx+u*57,(int)in->cy-v*57);
  106. }
  107.  
  108. void update_inst(INSTRUMENT *in,double val)
  109. {
  110.         int angl;
  111.         double u,v;
  112.     char help[30];
  113.  
  114.     setwritemode(COPY_PUT);
  115.     sprintf(help,"%6.2f %s",val,in->unit);
  116.     outtextxy(in->cx-4*strlen(help),in->y+65,help);
  117.     setwritemode(XOR_PUT);
  118.     angl=135-(int)(fabs(in->val)*90.0/in->e);
  119.     u=cos(angl*M_PI/180.0);
  120.     v=sin(angl*M_PI/180.0);
  121.     line(in->cx,in->cy,(int)in->cx+u*57,(int)in->cy-v*57);
  122.     in->val=val;
  123.     setwritemode(XOR_PUT);
  124.     angl=135-(int)(fabs(in->val)*90.0/in->e);
  125.     if (angl>135) angl=135;
  126.     if (angl<45)  angl=45;
  127.     u=cos(angl*M_PI/180.0);
  128.     v=sin(angl*M_PI/180.0);
  129.     line(in->cx,in->cy,(int)in->cx+u*57,(int)in->cy-v*57);
  130. }
  131.  
  132. 19Sep90/1147  Subject: dove tlm 3/3   de DH8BAG @ DB0HB
  133.  
  134. /* File dovetlm.c */
  135. #include <stdio.h>
  136. #include <string.h>
  137. #include <assert.h>
  138. #include <analog.h>
  139. #include <graphics.h>
  140. #include <stdlib.h>
  141. #include <ext.h>
  142. #include <math.h>
  143. #include <tos.h>
  144.  
  145. #define TELEMETRIE "dove_2.tlm"
  146. #define exp10(a) pow(10,a)
  147.  
  148. INSTRUMENT inst[58];
  149. int valid[58];
  150.  
  151. typedef struct {
  152.         char name[16];
  153.         double c,b,a;
  154.         char unit[7];
  155. } TLM_ENTRY;
  156.  
  157. static TLM_ENTRY tlm[] = {
  158.  
  159. "Rx E/F Audio(W)",0,0.0246,0,"V(p-q)",
  160. "Rx E/F Audio(N)",0,0.0246,0,"V(p-q)",
  161. "Mixer Bias V"   ,0,0.0102,0,"Volts",
  162. "Osc. Bisd V"    ,0,0.0102,0,"Volts",
  163. "Rx A Audio (W)" ,0,0.0246,0,"V(p-q)",
  164. "Rx A Audio (N)" ,0,0.0246,0,"V(p-p)",
  165. "Rx A DISC"      ,10.427,-0.09274,0,"kHz",
  166. "Rx A S meter"   ,0,1,0,"Counts",
  167. "Rx E/F DISC"    ,9.6234,-0.09911,0,"kHz",
  168. "Rx E/F S meter" ,0,1,0,"Counts",
  169. "+5Volt Bus"     ,0,0.0305,0,"Volts",
  170. "+5V Rx Current" ,0,0.0001,0,"Amps",
  171. "+2.5V  VREF"    ,0,0.0108,0,"Volts",
  172. "8.5V BUS"       ,0,0.0391,0,"Volts",
  173. "IR Detector"    ,0,1,0,"Counts",
  174. "LO Monitor I"   ,0,0.000037,0,"Amps",
  175. "+10V BUS"       ,0,0.05075,0,"Volts",
  176. "GASFET Bias I"  ,0,0.000026,0,"Amps",
  177. "Ground REF"     ,0,0.01,0,"Volts",
  178. "+Z Array V"     ,0,0.10230,0,"Volts",
  179. "RX Temp"        ,101.05,-0.6051,0,"Deg. C",
  180. "+X (RX) temp"   ,101.05,-0.6051,0,"Deg. C",
  181. "Bat 1 V"        ,1.7932,-0.0034084,0,"Volts",
  182. "Bat 2 V"        ,1.7978,-0.0035316,0,"Volts",
  183. "Bat 3 V"        ,1.8046,-0.0035723,0,"Volts",
  184. "Bat 4 V"        ,1.7782,-0.0034590,0,"Volts",
  185. "Bat 5 V"        ,1.8410,-0.0038355,0,"Volts",
  186. "Bat 6 V"        ,1.8381,-0.0038450,0,"Volts",
  187. "Bat 7 V"        ,1.8568,-0.0037757,0,"Volts",
  188. "Bat 8 V"        ,1.7868,-0.0034068,0,"Volts",
  189. "Array V"        ,7.2050,0.0720,0,"Volts",
  190. "+5V Bus"        ,1.9320,0.0312,0,"Volts",
  191. "+8.5V Bus"      ,5.2650,0.0173,0,"Volts",
  192. "+10V Bus"       ,7.4690,0.021765,0,"Volts",
  193. "BCR Set Point"  ,-8.7620,1.1590,0,"Counts",
  194. "BCR Load Cur"   ,-0.0871,0.00698,0,"Amps",
  195. "+8.5V Bus Cur"  ,-0.00920,0.001899,0,"Amps",
  196. "+5V Bus Cur"    ,0.00502,0.00431,0,"Amps",
  197. "-X Array Cur"   ,-0.01075,0.00215,0,"Amps",
  198. "+X Array Cur"   ,-0.01349,0.00270,0,"Amps",
  199. "-Y Array Cur"   ,-0.01196,0.00239,0,"Amps",
  200. "+Y Array Cur"   ,-0.01141,0.00228,0,"Amps",
  201. "-Z Array Cur"   ,-0.01653,0.00245,0,"Amps",
  202. "+Z Array Cur"   ,-0.01137,0.00228,0,"Amps",
  203. "Ext Power Cur"  ,-0.02000,0.00250,0,"Amps",
  204. "BCR Input Cur"  ,0.06122,0.00317,0,"Amps",
  205. "BCR Output Cur" ,-0.01724,0.00345,0,"Amps",
  206. "Bat 1 Temp"     ,101.05,-0.6051,0,"Deg. C",
  207. "Bat 2 Temp"     ,101.05,-0.6051,0,"Deg. C",
  208. "Baseplt Temp"   ,101.05,-0.6051,0,"Deg. C",
  209. "FM TX#1 RF OUT" ,0.0256,-0.000884,0.0000836,"Watts",
  210. "FM TX#2 RF OUT" ,-0.0027,0.001257,0.0000730,"Watts",
  211. "PSK TX HPA Temp",101.05,-0.6051,0,"Deg. C",
  212. "+Y Array Temp"  ,101.05,-0.6051,0,"Deg. C",
  213. "RC PSK HPA Temp",101.05,-0.6051,0,"Deg. C",
  214. "RC PSK BP Temp" ,101.05,-0.6051,0,"Deg. C",
  215. "+Z Array Temp"  ,101.05,-0.6051,0,"Deg. C",
  216. "S band TX Out"  ,-0.0451,0.00403,0,"Watts",
  217. "S band HPA Temp",101.05,-0.6051,0,"Deg. C"
  218. };
  219.  
  220. FILE *in;
  221. char *cursym; /* das aktuelle symbol */
  222.  
  223. char *scan(char *t) /* liefert das nächste token */
  224. {
  225.         char *p;
  226.  
  227.         static char buffer[100]="";
  228.  
  229.         p=strtok(NULL,t);
  230.         while (p==NULL)
  231.         {
  232.                 if (fgets(buffer,100,in)==NULL)
  233.                 {
  234.                         fclose(in);
  235.                         getch();
  236.                         exit(0);
  237.                 }
  238.                 p=strtok(buffer,t);
  239.         }
  240.         cursym=p;
  241.         return(p);
  242. }
  243.  
  244. void rest(void) /* überliest "ctl UI pid F0\n" */
  245. {
  246.     assert(!strcmp(cursym,"ctl"));
  247.         scan(" ");
  248.     assert(!strcmp(cursym,"UI"));
  249.         scan(" ");
  250.     assert(!strcmp(cursym,"pid"));
  251.         scan(" \n");
  252.     assert(!strcmp(cursym,"F0"));
  253.     scan(" \n");
  254. }
  255.  
  256. void s7(void) /* Dekodiert TLM    */
  257. {
  258.         int addr,value;
  259.         double val_real;
  260.         rest();
  261.         while(strlen(cursym)==5 && cursym[2]==':')
  262.         {
  263.                 sscanf(cursym,"%x:%x",&addr,&value);
  264.                 val_real=(value*value)*tlm[addr].a+value*tlm[addr].b+tlm[addr].c;
  265.                 if (valid[addr])
  266.                         update_inst(&inst[addr],val_real);
  267.                 scan(" \n");
  268.         }
  269. }
  270.  
  271. void s6(void) /* Dekodiert TIME-1 */
  272. {
  273.         rest();
  274.         scan("\n");
  275.         /* printf("%s\n",cursym); */
  276.         scan(" \n");
  277. }
  278.  
  279. void s5(void) /* Dekodiert WASH   */
  280. {}
  281.  
  282. void s4(void) /* Dekodiert LSTAT  */
  283. {}
  284.  
  285. void s3(void) /* Dekodiert STATUS */
  286. {}
  287.  
  288. void s2(void) /* Sucht Zielrufzeichen */
  289. {
  290.         while(!strcmp(cursym,"to"))
  291.                 scan(" ");
  292.         if (!strcmp(cursym,"STATUS")) {
  293.                 scan(" ");
  294.                 s3();
  295.         }
  296.         if (!strcmp(cursym,"LSTAT")) {
  297.                 scan(" ");
  298.                 s4();
  299.         }
  300.         if (!strcmp(cursym,"WASH")) {
  301.                 scan(" ");
  302.                 s5();
  303.         }
  304.         if (!strcmp(cursym,"TIME-1")) {
  305.                 scan(" ");
  306.                 s6();
  307.         }
  308.         if (!strcmp(cursym,"TLM")) {
  309.                 scan(" ");
  310.                 s7();
  311.         }
  312. }
  313.  
  314. void s1(void) /* Prüft auf "DOVE-1" */
  315. {
  316.         if (!strcmp(cursym,"DOVE-1")) {
  317.                 scan(" ");
  318.                 s2();
  319.         }
  320. }
  321.  
  322. void s0(void) /* sucht "fm" als Anfang des Monitorheaders */
  323. {
  324.         while (1) {
  325.                 scan(" ");
  326.                 if (!strcmp(cursym,"fm")) {
  327.                         scan(" ");
  328.                         s1();
  329.                 }
  330.         }
  331. }
  332.  
  333. void init(void)
  334. {
  335.         int i;
  336.         int max;
  337.         double help,factor;
  338.     int n=0;
  339.  
  340.         if ((in=fopen(TELEMETRIE,"r"))==NULL)
  341.         {
  342.                 perror("Error");
  343.                 exit(errno);
  344.         }
  345.         /* in=stdaux für realtime anzeige der daten vom tnc */
  346.         for (i=0;i<58;i++)
  347.                 valid[i]=0;
  348.         for (i=0;i<58 && n < 20;i++) {
  349.             help=tlm[i].a*256.0*256.0; /* Die folgenden Zeilen versuchen einen    */
  350.             help+=tlm[i].b*256.0;      /* vernüftigen Skalenendwert zu berechnen */
  351.             help+=tlm[i].c;
  352.             help=fabs(help);
  353.             factor=floor(log10(help));
  354.             help/=exp10(factor);
  355.             help=ceil(help);
  356.             help*=exp10(factor);
  357.             max=(int)help;
  358.             if (max > 1)
  359.             {
  360.                         init_inst(&inst[i],10+125*(n%5),99*(n/5),tlm[i].unit,0,max,tlm[i].name);
  361.                         draw_inst(&inst[i]);
  362.                         valid[i]=1;
  363.                         n++;
  364.                 }
  365.         }
  366. }
  367.  
  368. /* Das Telemetriefile wird mit einem "Deterministischen Endlichen     *
  369. *  Automaten" (kurz DEA) analysiert. Es werden Daten im Monitorformat *
  370. *  der WA8DED/TF erwartet. Es werden nur die Blöcke an "TLM" aus-    *
  371. *  gewertet und nur die ersten zwanzig. Dieses Programm ist auch nur  *
  372. *  als Anregung gedacht und hat sicherlich die Überarbeitung nötig  */
  373.  
  374. void main(void)
  375. {
  376.         int graphdriver = DETECT, /* automatische */
  377.         graphmode;                /* Erkennung */
  378.  
  379.     initgraph(&graphdriver, &graphmode, "\TC");
  380.         atexit(closegraph);
  381.         init();
  382.         s0();
  383.         exit(0);
  384. }
  385.  
  386.